<template>
  <div>
    <el-menu
      :default-active="activeIndex"
      class="el-menu-demo"
      mode="horizontal"
      @select="handleSelect"
      router
      style="width:522px;margin:0 auto"
    >
      <el-menu-item index="/list">全部</el-menu-item>
      <el-menu-item index="/digital">3C数码</el-menu-item>
      <el-menu-item index="/books">书籍</el-menu-item>
      <el-menu-item index="/life">生活用品</el-menu-item>
      <el-menu-item index="/sandc">服饰</el-menu-item>
      <el-menu-item index="/beauty">美妆</el-menu-item>
      <el-menu-item index="/others">其他</el-menu-item>
    </el-menu>
    <div style="text-align:center">
      <el-input
        v-model="input"
        placeholder="请输入商品内容"
        style="width:300px"
      ></el-input>
      <el-button
        type="primary"
        @click="search(input)"
      >搜索</el-button>
    </div>
    <router-view></router-view>
  </div>
</template>
<script>
export default {
  data: () => ({
    activeIndex: '/listall',
    activeIndex2: '1',
    input: ''
  }),
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath)
    },
    async search(value) {
      const res = await this.$http.search(value)
      this.$router.push({
        path: '/search/' + value,
        query: {
          value: res
        }
      })
    }
  },
  created() {
    console.log(this.$store.state)
  }
}
</script>
<style lang="scss" scoped>
</style>
